<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>佣金管理</title>
<link rel="stylesheet" type="text/css" media="screen"
	href="../../global/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" media="screen"
	href="../../global/css/dataTables.bootstrap.min.css">
<link rel="stylesheet" type="text/css" media="screen"
	href="../../global/layui/css/layui.css">
</head>
<body>
	<div>
		<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
			<header style="height: 100%">
			</header>

			<div>
				<div class="widget-body no-padding">
					<table id="dt-table"
						class="table table-striped table-bordered table-hover"
						style="width: 100%">
						<thead>
							<tr>
							</tr>
							<tr>
								<th style="width: 10%">类别</th>
								<th style="width: 5%">平台</th>
								<th style="width: 5%">地市</th>
								<th style="width: 5%">区县</th>
								<th style="width: 5%">会员</th>
								<th style="width: 5%">导购</th>
								<th style="width: 5%">讲师</th>
								<th style="width: 5%">经理</th>
								<th style="width: 5%">联盟</th>
								<th style="width: 10%">最后修改时间</th>
								<th style="width: 10%">操作</th>
							</tr>
						</thead>
						<tbody>
						</tbody>
					</table>
				</div>
			</div>
		</div>
	</div>
</body>
</html>

<script type="text/javascript"
	src="../../global/js/libs/jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="../../global/js/jq.js"></script>
<script type="text/javascript"
	src="../../global/js/plugin/datatables/jquery.dataTables.min.js"></script>
<script type="text/javascript"
	src="../../global/js/plugin/datatables/dataTables.bootstrap.min.js"></script>
<script type="text/javascript" src="../../global/layui/layui.js"></script>
<script type="text/javascript" src="../../global/js/my/permission.js"></script>
<script type="text/javascript">
	var pers = checkPermission();

	var example;

	function init() {
		
		example = $('#dt-table')
				.DataTable(
						{
							"searching" : false,
							"processing" : false,
							"serverSide" : true,
							"bPaginate":false,
							"bInfo" : false,
							"language" : {
								"url" : "/global/js/plugin/datatables/Chinese.lang"
							},
							"ajax" : {
								"url" : "/clyjCom/getComList",
								"type" : "get",
								"error" : function(xhr, textStatus, errorThrown) {
									var msg = xhr.responseText;
									console.log(msg);
									var response = JSON.parse(msg);
									var code = response.code;
									var message = response.message;
									if (code == 400) {
										layer.msg(message);
									} else if (code == 401) {
										localStorage.removeItem("token");
										layer.msg("token过期,请先登录", {
											shift : -1,
											time : 1000
										}, function() {
											location.href = '/login.html';
										});
									} else if (code == 403) {
										console.log("未授权:" + message);
										layer.msg('未授权');
									} else if (code == 500) {
										layer.msg('系统错误:' + message);
									}
								}
							},
							"dom" : "<'dt-toolbar'r>t<'dt-toolbar-footer'<'col-sm-10 col-xs-12 hidden-xs'i><'col-xs-12 col-sm-10' p v>>",
							"columns" : [
									{
										"data" : "giftName",
										"defaultContent" : ""
									},
									{
										"data" : "admin",
										"defaultContent" : "",
										"render" : function(data, type, row) {
											if(!row['commissionType'] || data==null || data=="null" || data=="")
												return data;
											if(row['commissionType']=="1")
												return data+"元";
											if(row['commissionType']=="2")
												return data+"%";
										}
									},
									{
										"data" : "city",
										"defaultContent" : "",
										"render" : function(data, type, row) {
											if(!row['commissionType'] || data==null || data=="null" || data=="")
												return data;
											if(row['commissionType']=="1")
												return data+"元";
											if(row['commissionType']=="2")
												return data+"%";
										}
									},
									{
										"data" : "country",
										"defaultContent" : "",
										"render" : function(data, type, row) {
											if(!row['commissionType'] || data==null || data=="null" || data=="")
												return data;
											if(row['commissionType']=="1")
												return data+"元";
											if(row['commissionType']=="2")
												return data+"%";
										}
									},
									{
										"data" : "member",
										"defaultContent" : "",
										"render" : function(data, type, row) {
											if(!row['commissionType'] || data==null || data=="null" || data=="")
												return data;
											if(row['commissionType']=="1")
												return data+"元";
											if(row['commissionType']=="2")
												return data+"%";
										}
									},
									{
										"data" : "shopper",
										"defaultContent" : "",
										"render" : function(data, type, row) {
											if(!row['commissionType'] || data==null || data=="null" || data=="")
												return data;
											if(row['commissionType']=="1")
												return data+"元";
											if(row['commissionType']=="2")
												return data+"%";
										}
									},
									{
										"data" : "lectorer",
										"defaultContent" : "",
										"render" : function(data, type, row) {
											if(!row['commissionType'] || data==null || data=="null" || data=="")
												return data;
											if(row['commissionType']=="1")
												return data+"元";
											if(row['commissionType']=="2")
												return data+"%";
										}
									},
									{
										"data" : "manage",
										"defaultContent" : "",
										"render" : function(data, type, row) {
											if(!row['commissionType'] || data==null || data=="null" || data=="")
												return data;
											if(row['commissionType']=="1")
												return data+"元";
											if(row['commissionType']=="2")
												return data+"%";
										}
									},
									{
										"data" : "alliance",
										"defaultContent" : "",
										"render" : function(data, type, row) {
											if(!row['commissionType'] || data==null || data=="null" || data=="")
												return data;
											if(row['commissionType']=="1")
												return data+"元";
											if(row['commissionType']=="2")
												return data+"%";
										}
									},
									{
										"data" : "updateTime",
										"defaultContent" : "",
										"render" : function(data) {
											if (data == null || data == "") {
												return data;
											}
											var dateee = new Date(data)
													.toJSON();
											var date = new Date(+new Date(
													dateee) + 8 * 3600 * 1000)
													.toISOString().replace(
															/T/g, ' ').replace(
															/\.[\d]{3}Z/, '')
											data = date
											return data;
										}
									},

									{
										"data" : "",
										"defaultContent" : "",
										"orderable" : false,
										"render" : function(data, type, row) {
											var href = "addCommission.html?giftId="+row['giftId']+"&commissionId="+row['commissionId']+"&giftName="+encodeURI(encodeURI(row['giftName']))+"&commissionType="+row['commissionType']
											+"&admin="+row['admin']+"&city="+row['city']+"&country="+row['country']+"&member="+row['member']+"&shopper="+row['shopper']+"&lectorer="+row['lectorer']
											+"&manage="+row['manage']+"&alliance="+row['alliance'];
											var edit = buttonEdit(href,
													"gift:query", pers);

											return edit;
										}
									}, ],
							"order" : [ [ 2, "desc" ] ]
						});
	}

	layui.use('layer', function() {
		var layer = layui.layer;
	});


	$("#searchBt").click(function() {
		example.ajax.reload();
	});

	init();
</script>